<?php
namespace Users\Model;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Paginator\Paginator;
use Zend\Db\Sql\Expression;
class NewsletterTable
{
    protected $tableGateway;
	protected $select;
    public function __construct(TableGateway $tableGateway)
    {
        $this->tableGateway = $tableGateway;
		$this->select = new Select();
    }
	public function addNewsLetterToUsers($subject,$message)
    {
		$data = array(
			'subject'            => $subject, 	
			'message_content' 	 => $message,
			'status' 		     => 1, 
			'added_date' 	     => date('Y-m-d H:i:s'), 				
			'updated_date' 	     => date('Y-m-d H:i:s'), 				
		);		
		$this->tableGateway->insert($data);
		return $this->tableGateway->lastInsertValue;	
    }
	public function allNewsletters()
    {
		$select = $this->tableGateway->getSql()->select();
		$select->where('status=1');	
		$resultSet = $this->tableGateway->selectWith($select);	
		return $resultSet;
    }
	public function getnewsletter($news_id){
		//echo "<pre>";print_r($news_id);exit;
		$select = $this->tableGateway->getSql()->select();			
		$select->where('newsletter_id="'.$news_id.'"');	
		$resultSet = $this->tableGateway->selectWith($select);
		return $resultSet;		
	}
	
	
}